import { getItem, setItem, TOKEN, newAxiosRequest } from '@hs-admin/utils'
import { message } from '@hs-admin/utils'

const { mainAxios } = newAxiosRequest({
  baseUrl: `${import.meta.env.VITE_BOARD_API_URL}/api/data-dashboard`,
  loginUrl: '/v1/oauth/access-token',
  refreshTokenUrl: {
    axiosConfig: {
      url: '/v1/oauth/refresh-access-token',
      method: 'post'
    },
    setToken: (res: { access_token: string; token_type: string }) => setItem(TOKEN, res.access_token)
  },
  getToken: () => getItem(TOKEN),
  handleMessage: message,
  loadingFunction: null
})

export default mainAxios
